//
//  LevelSelectionScreen.m
//  AngerDragon
//
//  Created by gaotime_macbook_2 on 11-12-2.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "LevelSelectionScreen.h"
#import "WeaponUpgradesScreen.h"
#import "GameRunScreen.h"

@implementation LevelSelectionScreen

- (void) dealloc {
	[super dealloc];
	
	CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
}

/**
 * @brief 点击 运行游戏
 *
 * @param[in] (id) sender
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
-(void) LevelSelectionScreen_runGameClickCallback: (id) sender{
	
	/// 加载第一场景的图片资源
	[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"level_village.plist" textureFile:@"level_village.png"];
	
	
	CCScene *a_p_cls_game_run_screen_scene = [GameRunScreen scene];
	[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInL transitionWithDuration:1.2f 
																																									 scene:a_p_cls_game_run_screen_scene]];	
}

/**
 * @brief 点击了 返回主菜单 按钮 
 *
 * @param[in] (id) sender
 * @param[out] nil
 *
 * @return void
 *
 * @note注解
 *
 */
-(void) LevelSelectionScreen_goBackClickCallback: (id) sender {
	CCScene *a_p_cls_weapon_upgrades_screen_scene = [CCScene node];
	[a_p_cls_weapon_upgrades_screen_scene addChild:[WeaponUpgradesScreen node]];
	
	[[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInL transitionWithDuration:1.2f 
																																									 scene:a_p_cls_weapon_upgrades_screen_scene]];	
}

-(id) init {
	
	if ((self = [super init])) {
		
		CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
		
		/// go back 按钮, 使用 位图字体
		CCLabelBMFont *a_p_cls_go_back_label = [CCLabelBMFont labelWithString:@"Go back" fntFile:@"font01.fnt"];
	
		CCMenuItemLabel *a_p_cls_menu_go_back = [CCMenuItemLabel itemWithLabel:a_p_cls_go_back_label 
																																		target:self 
																																	selector:@selector(LevelSelectionScreen_goBackClickCallback:)];
		//a_p_cls_menu_go_back.scale = 1.5;
	
		/// run game 按钮, 使用 位图字体
		CCLabelBMFont *a_p_cls_continue_label = [CCLabelBMFont labelWithString:@"Run" fntFile:@"font01.fnt"];
	
		CCMenuItemLabel *a_p_cls_continue = [CCMenuItemLabel itemWithLabel:a_p_cls_continue_label 
																																target:self 
																															selector:@selector(LevelSelectionScreen_runGameClickCallback:)];
	
	
		// 组成菜单局
		CCMenu *a_p_cls_menu_list = [CCMenu menuWithItems:
															  
															 
															 a_p_cls_menu_go_back, a_p_cls_continue,
															 nil];  
		/// 垂直排成一排
		[a_p_cls_menu_list alignItemsInColumns:
			[NSNumber numberWithUnsignedInt:2], nil];  
	
		/// 要想手动修改 菜单控件的坐标, 必须在布局动作完成后(alignItemsInColumns 布局动作)
		a_p_cls_menu_go_back.position = 
			ccp(a_p_cls_menu_go_back.contentSize.width - [[CCDirector sharedDirector] winSize].width / 2, 
					a_p_cls_menu_go_back.contentSize.height - [[CCDirector sharedDirector] winSize].height / 2);
	
		a_p_cls_continue.position = 
			ccp([[CCDirector sharedDirector] winSize].width/2 - a_p_cls_continue.contentSize.width, 
					a_p_cls_continue.contentSize.height - [[CCDirector sharedDirector] winSize].height / 2);
	
		/// 
		[self addChild: a_p_cls_menu_list];
	
	}
	return self;
}



@end
